<?php
/**
 * PHP By Example
 *
 * @copyright 2014 Michel Corne <mcorne@yahoo.com>
 * @license   http://www.opensource.org/licenses/gpl-3.0.html GNU GPL v3
 */
?>

<?php foreach ($this->test_validations as $example_id => $validation):
          $status = $validation['status'];?>

  <?php if ($status == 'test_success'):?>
    <div class="title green">Example #<?=$example_id + 1;?></div>
    <div class="block green_border">

  <?php elseif ($status == 'test_not_validated'):?>
    <div class="title gray">Example #<?=$example_id + 1;?></div>
    <div class="block gray_border">

  <?php elseif ($status == 'test_failed'):?>
    <div class="title red">Example #<?=$example_id + 1;?></div>
    <div class="block red_border">

  <?php else:?>
    <div class="title orange">Example #<?=$example_id + 1;?></div>
    <div class="block orange_border">
  <?php endif;?>

    <table>

       <tr>
         <td class="variable">$input</td>
         <td class="operator">=</td>
         <td><?=$this->_output->display_var_value($this->_function->examples[$example_id]);?></td>
       </tr>

       <tr>
         <?php if ($status != 'test_missing'):?>
           <td class="variable">$expected_output</td>
         <?php else:?>
           <td class="orange">$expected_output</td>
         <?php endif;?>

         <td class="operator">=</td>

         <?php if ($status == 'test_success' or $status == 'test_not_validated'):?>
           <td class="variable">$test_output</td>
         <?php elseif ($status == 'test_failed'):?>
           <td>
             <?php if (isset($validation['expected_result'])):?>
               <?=$this->_output->display_var_value($validation['expected_result']);?>
             <?php else:?>
               none
             <?php endif;?>
           </td>
         <?php else:?>
           <td>MISSING</td>
         <?php endif;?>
       </tr>

       <tr>
         <?php if ($status == 'test_success'):?>
           <td class="green">$test_output</td>
         <?php elseif ($status == 'test_not_validated'):?>
           <td class="gray">$test_output</td>
         <?php elseif ($status == 'test_failed'):?>
           <td class="red">$test_output</td>
         <?php else:?>
           <td class="variable">$test_output</td>
         <?php endif;?>

         <td class="operator">=</td>

         <td><?=$this->_output->display_var_value($validation['test_result']);?></td>
       </tr>

     </table>
  </div>

<?php endforeach;?>
